package com.fengxu.springcloud.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

@RestController
public class OrderNacosController {

    // 服务提供者注册进nacos的服务名
    public static final String PAYMENT_SERVICE = "http://nacos-payment-provider";

    @Autowired
    private RestTemplate restTemplate;

    @GetMapping("/consumer/payment/{id}")
    public String findPayment(@PathVariable("id")String id) {
        return restTemplate.getForObject(PAYMENT_SERVICE+"/payment/nacos/" + id,String.class);
    }

}
